public class FourthQtnThread {
    private static   int account=0;




    public synchronized   static void showAccount(int money){
        account+=money;
        System.out.println(Thread.currentThread().getName()+"在账户存了"+money+"块，余额为："+account);

    }
    public static void main(String[] args) {

        for (int i =1; i <=2 ; i++) {
            new Thread(()->{
                for (int j = 0; j < 3; j++) {
                    showAccount(100);
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            },"选手"+i).start();
        }
    }
}
